<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/echarts.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-1.11.1.js"></script>
    <style type="text/css">
        div {
            width: 600px;
            height: 400px;
            border: 1px solid #ff0000;
            margin: 0 auto;
            margin-top: 100px;
        }
    </style>
</head>
<body>
<div id="box"></div>
<script type="text/javascript">
    $(function () {
// 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('box'));
        $.ajax({
            url:'${pageContext.request.contextPath}/p/all',
            type:'post',
            dataType:'JSON',
            success:function (res) {
                console.log(res.names)
                console.log(res.numbers)
                // 指定图表的配置项和数据
                var option = {
                    xAxis: {
                        data:  res.names
                    },
                    yAxis: {},
                    series: [{
                        type: 'line',
                        data: res.numbers
                    }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        })

    })

</script>
</body>
</html>

